package com.industrial.operation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.industrial.common.core.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.industrial.common.log.annotation.Log;
import com.industrial.common.log.enums.BusinessType;
import com.industrial.common.security.annotation.RequiresPermissions;
import com.industrial.operation.domain.OperationSupport;
import com.industrial.operation.service.IOperationSupportService;
import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.page.TableDataInfo;

/**
 * 政府扶持Controller
 * 
 * @author Zhou_S
 * @date 2024-01-17
 */
@RestController
@RequestMapping("/support")
public class OperationSupportController extends BaseController
{
    @Autowired
    private IOperationSupportService operationSupportService;

    /**
     * 查询政府扶持列表
     */
    @RequiresPermissions("operation:support:list")
    @GetMapping("/list")
    public TableDataInfo list(OperationSupport operationSupport)
    {
        startPage();
        List<OperationSupport> list = operationSupportService.selectOperationSupportList(operationSupport);
        return getDataTable(list);
    }

    /**
     * 导出政府扶持列表
     */
    @RequiresPermissions("operation:support:export")
    @Log(title = "政府扶持", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperationSupport operationSupport)
    {
        List<OperationSupport> list = operationSupportService.selectOperationSupportList(operationSupport);
        ExcelUtil<OperationSupport> util = new ExcelUtil<OperationSupport>(OperationSupport.class);
        util.exportExcel(response, list, "政府扶持数据");
    }

    /**
     * 获取政府扶持详细信息
     */
    @RequiresPermissions("operation:support:query")
    @GetMapping(value = "/{baseId}")
    public AjaxResult getInfo(@PathVariable("baseId") String baseId)
    {
        return success(operationSupportService.selectOperationSupportByBaseId(baseId));
    }

    /**
     * 新增政府扶持
     */
    @RequiresPermissions("operation:support:add")
    @Log(title = "政府扶持", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperationSupport operationSupport)
    {
        return toAjax(operationSupportService.insertOperationSupport(operationSupport));
    }

    /**
     * 修改政府扶持
     */
    @RequiresPermissions("operation:support:edit")
    @Log(title = "政府扶持", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperationSupport operationSupport)
    {
        return toAjax(operationSupportService.updateOperationSupport(operationSupport));
    }

    /**
     * 删除政府扶持
     */
    @RequiresPermissions("operation:support:remove")
    @Log(title = "政府扶持", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseIds}")
    public AjaxResult remove(@PathVariable String[] baseIds)
    {
        return toAjax(operationSupportService.deleteOperationSupportByBaseIds(baseIds));
    }
}
